package com.zhitan.netty.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum RemoteStopErrorCodeEnum {

    /**
     * 远程停机命令失败原因
     */
    UNKNOWN((byte) -1, "未知"),
    SUCCESS((byte) 0x00, "无"),
    NOT_MATCH((byte) 0x01, "设备编号不匹配"),
    UN_USED((byte) 0x02, "枪未处于充电状态"),
    DEVICE_ERROR((byte) 0x03, "其他");

    private final byte code;
    private final String reason;

    /**
     * 根据code获取枚举
     */
    public static RemoteStopErrorCodeEnum getByCode(byte code) {
        for (RemoteStopErrorCodeEnum value : RemoteStopErrorCodeEnum.values()) {
            if (value.getCode() == code) {
                return value;
            }
        }
        return UNKNOWN;
    }
}
